package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.param.BaseParam;
import com.cskaoyan.bean.po.MarketCollect;
import com.cskaoyan.bean.wx.collect.WxCollectListVo;
import com.cskaoyan.config.exception.LoginAuthenException;
import com.cskaoyan.service.wx.WxCollectService;
import com.cskaoyan.util.UserIdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * oushao  2022-06-08   11:50
 */
@RestController
@RequestMapping("wx/collect")
public class WxCollectController {

    @Autowired
    WxCollectService wxCollectService;

    @GetMapping("list")
    public BaseRespVo list(BaseParam param,String type){

        WxCollectListVo wxCollectListVo = wxCollectService.query(param,type);

        return BaseRespVo.ok(wxCollectListVo);
    }

    @PostMapping("addordelete")
        public BaseRespVo addordelete(@RequestBody() MarketCollect marketCollect) throws LoginAuthenException {

        Integer userIdFromSubjectThrowException = UserIdUtil.getUserIdFromSubjectThrowException();
        
        wxCollectService.addordelete(marketCollect);

        return BaseRespVo.ok();

    }


}
